package httplib

import (
	"io"
	"net/http"
	"time"
)

type (
	IRequest interface {
		//设置头
		SetHeader(key, value string) *Request
		//设置cookie
		SetCookie(cookie *http.Cookie) *Request
		//设置超时时间
		SetTimeout(timeout time.Duration) *Request
		//设置发送参数
		SetQueryParams(v map[string]string) *Request
		//设置body
		SetBody(body io.Reader) *Request
		//设置body类型
		SetContentType(contentType string) *Request
		//执行
		Do() (*Response, error)
	}

	IResponse interface {
		Bytes() []byte
		String() string
		JSON(v interface{})
		StatusCode() int
		Headers() *http.Header
		Cookies() []*http.Cookie
	}
)

func Get(url string) IRequest {
	return NewRequest(url, "GET")
}

func Post(url string) IRequest {
	return NewRequest(url, "POST")
}

func Put(url string) IRequest {
	return NewRequest(url, "PUT")
}

func Patch(url string) IRequest {
	return NewRequest(url, "PATCH")
}

func Delete(url string) IRequest {
	return NewRequest(url, "DELETE")
}
